package com.tairanchina.wiki.restful.resource;

import com.tairanchina.wiki.api.model.navigation.*;
import com.tairanchina.wiki.api.model.wiki.navigation.*;

import javax.inject.Singleton;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import java.net.URI;

/**
 * Created by 周靖捷 on 2016/10/1.
 */
@Path("/")
@Singleton
public class NavigationResource {

    @Path("/{projectName}/navigation.md")
    @GET
    @Produces({"text/plain"})
    public String getNavigation(@PathParam("projectName") String projectName) {
        ProjectNavigation navigation = new ProjectNavigation();
        navigation.setTitle("泰玄网络wiki系统")
                .addNavigationItems(new ProjectSubNavigation().setTitle("HOME").setLinkedResource(URI.create("index.md")))
                .addNavigationItems(new ProjectSubNavigation().setTitle("版本说明"))
                .addNavigationItems(new ProjectSubNavigationGroupTips().setTips("版本说明"))
                .addNavigationItems(new ProjectSubNavigationElement().setTitle("版本说明").setLinkedResource(URI.create("index.md")))
                .addNavigationItems(new ProjectSubNavigationSeperator());
        System.out.println(navigation.toMarkdown());
        return navigation.toMarkdown();
    }

    @Path("/{projectName}/index.md")
    @GET
    @Produces({"text/plain"})
    public String index(@PathParam("projectName") String projectName) {
        return "研发Wiki\n" +
                "=======\n" +
                "\n" +
                "本Wiki系统主要解决研发成员对公司项目、框架、结构等不了解的问题，提供对公有项目的介绍，不提供各业务功能介绍。\n" +
                "\n" +
                "项目结构\n" +
                "--------\n" +
                "\n" +
                "项目结构分为为，Rest业务层，Service服务层，前端界面/APP层\n" +
                "\n" +
                "项目管理\n" +
                "-------\n" +
                "\n" +
                "使用 _Git_ 作为代码协同工具\n" +
                "\n" +
                "使用 _Maven_ 作为项目管理工具（版本、依赖、打包等）\n" +
                "\n" +
                "- - - -";
    }
}
